package com.xinan.weixin.resource;

import com.jfinal.ext.plugin.tablebind.TableBind;
import com.jfinal.kit.StringKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

import java.sql.Timestamp;
import java.util.List;

@TableBind(tableName = "wx_resource")
public class WxResource extends Model<WxResource>{
    public static final WxResource dao = new WxResource();

    //columns START
    private String ID = "id";  //
    private String BT = "bt";  //标题
    private String NR = "nr";  //内容
    private String LRDATE = "lrdate";  //录入日期
    private String YXBZ = "yxbz";  //有效标志
    private String IMG = "img";  //

    public void setId(int value) {
        set(ID, value);
    }

	public int getId() {
		return get(ID);
	}
    public void setBt(String value) {
        set(BT, value);
    }

	public String getBt() {
		return get(BT);
	}
    public void setNr(String value) {
        set(NR, value);
    }

	public String getNr() {
		return get(NR);
	}
    public void setLrdate(Timestamp value) {
        set(LRDATE, value);
    }

	public Timestamp getLrdate() {
		return get(LRDATE);
	}
    public void setYxbz(String value) {
        set(YXBZ, value);
    }

	public String getYxbz() {
		return get(YXBZ);
	}
    public void setImg(String value) {
        set(IMG, value);
    }

	public String getImg() {
		return get(IMG);
	}
	//columns END

    public List<WxResource> findAll() {
        return find("select * from wx_resource");
    }
    /**
     * @param   where
     * @return  Record
     */
    public List<Record> findAlls(String where) {
        String sqlExp = " from wx_resource";
        if(StringKit.notBlank(where)){
                sqlExp += " where " + where;
        }
                return Db.find( "select * " +sqlExp );

    }

    public Page<WxResource> page(int pageNumber, int pageSize, String where) {
        String sqlExp = "from wx_resource";
        if(StringKit.notBlank(where)){
            sqlExp += " where " + where;
        }
        return paginate(pageNumber, pageSize, "select *", sqlExp);
    }
}

